<template>
  <div class="mulu">
    <a-page-header class="header" @back="goBack" title="返回"></a-page-header>
    <div v-if="!list">
      <div class="loading"></div>
    </div>
    <ul v-else class="list">
      <!-- <li v-for="item in list" :key="item.chapterUrl" @click="goReader(item.chapterUrl)">
        {{item.chapterName}}
      </li>-->
      <router-link
        tag="li"
        v-for="(item,index) in list"
        :key="item.chapterUrl"
        :to="{name:'reader',query:{bookUrl:bookinfo.url,bookName:bookinfo.bookName,chapterUrl:item.chapterUrl,currentChapter:index}}"
      >{{item.chapterName}}</router-link>
    </ul>
  </div>
</template>

<script>
  import {PageHeader} from 'ant-design-vue'

export default {
  components:{
    'a-page-header':PageHeader
  },
  data: () => {
    return {
      over: false
    };
  },
  created() {},
  props: ["list", "bookinfo"],
  methods: {
    goBack() {
      this.$emit("hideList");
    },
    goReader(chapterUrl) {
      this.$router.push({
        name: "reader",
        query: {
          bookUrl: this.bookinfo.url,
          chapterUrl: chapterUrl,
          bookName: this.bookinfo.bookName
        }
      });
    }
  }
};
</script>

<style lang='less' scoped>
@media screen and (max-width: 420px) {
  
  .mulu {
    
    position: fixed;
    top: 0;
    background: white;
    width: 100%;
    height: 100%;
    overflow: auto;
    .header{
      position: fixed;
      background: white;
      width: 100%;
    }
    ul {
      margin-top: 50px;
      font-size: 14px;
      line-height: 2;
      padding: 10px;
      li {
        border-bottom: 1px dashed lightgray;
      }
    }
    .pageHeader {
      position: fixed;
      top: 0;
      background: white;
      line-height: 30px;
      width: 100%;
    }
  }
}
@media screen and (min-width: 420px) {
  .loading{
    margin-top: 30px
  }
  .pageHeader {
    display: none;
  }
  .mulu {
    margin-top: 30px;
    border: 2px solid lightgray;
    padding: 10px;
    ul {
      display: flex;
      justify-content: space-around;
      flex-wrap: wrap;
      li {
        width: 50%;
        font-size: 14px;
        line-height: 30px;
        border-bottom: 1px dashed lightgray;
        cursor: pointer;
      }
    }
  }
}
</style>